package com.example.gybicycle.common.util;

import  com.alibaba.fastjson.JSON;
import  com.alibaba.fastjson.JSONObject;
import com.wechat.pay.java.service.partnerpayments.app.model.Transaction;

import java.math.BigDecimal;
import java.math.RoundingMode;

public class test {
    public static void main(String[] args) {

        String str="{\"id\":\"f34c7e93-318c-576a-aaef-cb5635198201\"," +
                "\"create_time\":\"2024-07-18T17:27:46+08:00\"," +
                "\"resource_type\":\"encrypt-resource\"," +
                "\"event_type\":\"TRANSACTION.SUCCESS\"," +
                "\"summary\":\"鏀\uE219粯鎴愬姛\"," +
                "\"resource\":{" +
                   "\"original_type\":\"transaction\"" +
                    ",\"algorithm\":\"AEAD_AES_256_GCM\"" +
                  ",\"ciphertext\":\"BdzZTO6SbGjaFQjR5CP/dn7pQVXjUs/mY1uMJBwbwSg2KqXKunZcxtJOEFcZFgE9ka9ODnFSvw4Dfj9lGlkCmBBKVU0aO7Sg9hCXU0yV+l3XPuVgAahWJRHXFu0XUmoNLGNHW0kDpiCZdGX82fv3I/JNt84Zdyf8lmg2LLC6KZszkVckrGZUpvuRgBJTiSsVy2tAvFOWbGU69BBTEFzMLHbeGq6iWHmJi//mO5nrX64dcDvpx9nL+JjnjcPrxNtG7PWH0EGP3B5NyOqAqqbCnmOS9TPme1yN9lsPN4PmEV3HpAGAV2Mu9lfgz1QflNgDbdFEdc+7qXmXnBRG7LAZHz6uLG0Bgbpod3oV0ntNEsGOlCYmhVZr3x4BpBSf/34QKFlgovXz5fFVmtBtzNqIPd+PfW3C2pP1+CNOSTXXiM1bneRxbbB8JJqHB57K89/0TSVuzF5B0BJMssRsvlm61EfLFiTZ6/h5T2zNHQV0GWz6G6pulXcXvT5t0uFI0WshsdHHSP6FdfPZuBzDsNsR5qcBGEDT+NFBNaCiUdmW8OLeYRGSRfF6tCWUzJnXeqr8H0bpbH7SK3h7KmWZ98+G33c=\"" +
                  ",\"associated_data\":\"transaction\"" +
                  ",\"nonce\":\"359EgVQsc4TG\"}}";

//        String strs="ORDER2933";
//        System.out.println(strs.contains("ORDER"));

        BigDecimal payMoney =new BigDecimal(0.0100);
        BigDecimal amountTotal = payMoney.multiply(new BigDecimal("100")).setScale(0, RoundingMode.DOWN);
//            amount.setTotal(amountTotal.intValue());
        System.out.println(Long.valueOf(amountTotal.intValue()));
        //退款金额
//        amountReq.setRefund());
        /* JSONObject object= JSON.parseObject(str);
        System.out.println(object);
        //附加数据
        String associatedData = (String) JSONUtil.getByPath(JSONUtil.parse(wechatDTO.getBody()), "resource.associated_data");
        //数据密文
        String ciphertext = (String) JSONUtil.getByPath(JSONUtil.parse(wechatDTO.getBody()), "resource.ciphertext");
        //随机串
        String nonce = (String) JSONUtil.getByPath(JSONUtil.parse(wechatDTO.getBody()), "resource.nonce");
        //解密
        try {
            //验签成功
            String decryptData = new AesUtil(wechatConfig.getApiV3Key().getBytes(StandardCharsets.UTF_8)).decryptToString(associatedData.getBytes(StandardCharsets.UTF_8), nonce.getBytes(StandardCharsets.UTF_8), ciphertext);
            //支付参数
            Transaction transaction = JSONObject.parseObject(decryptData, Transaction.class);
            log.info("参数-------" + JSONObject.toJSONString(transaction));
            //订单编号（本地生成）
            String outTradeNo = transaction.getOutTradeNo();
            //通过本地订单编号处理业务逻辑(并将付款编号保存到本地)
            log.info("订单编码" + outTradeNo);
            //业务逻辑处理
            if (transaction.getTradeState().equals(Transaction.TradeStateEnum.SUCCESS)) {

            }
        } catch (GeneralSecurityException | IOException e) {

            throw new IllegalArgumentException(e);
        }*/
          }
}
